# 编译器
CC = gcc

# 编译选项
CFLAGS = -Wextra -g

# 目标程序
TARGETS = heapq_test vector_test

# 源文件
SRCS = heapq.c vector.c

# 对象文件
OBJS = $(SRCS:.c=.o)

# 默认目标
all: $(TARGETS)

# 测试程序 heapq_test
heapq_test: heapq_test.o heapq.o vector.o
	$(CC) $(CFLAGS) -o $@ $^

# 测试程序 vector_test
vector_test: vector_test.o vector.o
	$(CC) $(CFLAGS) -o $@ $^

# 编译 .c 文件为 .o 文件
%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

# 清理生成的文件
clean:
	rm -f $(OBJS) $(TARGETS)

# 运行测试程序
run-tests: $(TARGETS)
	./heapq_test
	./vector_test

# 查看帮助信息
help:
	@echo "Usage:"
	@echo "  make all       - Build all targets"
	@echo "  make clean     - Clean up generated files"
	@echo "  make run-tests - Run all tests"
	@echo "  make help      - Show this help message"